package utils

import (
	"os"
	"path/filepath"
	"runtime"
	"strings"
)

func AddPath(npt string) {
	p := os.Getenv("PATH")
	splitChar := ":"
	if runtime.GOOS == "windows" {
		splitChar = ";"
	}
	paths := strings.Split(p, splitChar)
	found := false
	for _, pt := range paths {
		if filepath.FromSlash(pt) == filepath.FromSlash(npt) {
			found = true
			break
		}
	}
	if !found {
		paths = append(paths, filepath.Clean(npt))
		os.Setenv("PATH", strings.Join(paths, splitChar))
	}
}
